﻿<div class="span12" id="smallUserDetail">
    <div class="span4">
        <img class="thumbnail" src="/Content/images/small_user_placeholder.jpg" /></div>
    <div class="span8" data-bind="with:IndividuoDetalle">
        <h2>
            <span data-bind="text: $parent.NombreCompleto"></span>
        </h2>
        <p>
            <a href="mailto:#"><span data-bind="text: Email"></span></a>
        </p>
        <dl class="dl-horizontal">
            <dt>No Identificacion</dt>
            <dd>
                <span data-bind="text: NoIdentificacion"></span>
            </dd>
            <dt>Grupo Sanguineo</dt>
            <dd>
                <span data-bind="text: GrupoSanguineo"></span>
            </dd>
            <dt>Fecha Nacimiento</dt>
            <dd>
                <span data-bind="date: FechaNacimiento"></span>
            </dd>
        </dl>
    </div>
</div>
<script type="text/javascript">
    /// <reference path="../../knockout-2.1.0.js" />
    /// <reference path="../../knockout.mapping-latest.js" />
    /// <reference path="../shared/utils.js" />
    /// <reference path="../../jquery-1.7.2-vsdoc.js" />
    /// <reference path="../../knockout.wrap.js" />
    function IndividuoDetalle(data) {
        var self = this;

        self.Load = function (info) {
            ko.mapping.fromJS(info, {}, this);
        };

        if (data)
            self.Load(data);
    }

    function IndividuoDetalleViewModel() {
        var self = this;
        self.Load = function (id) {
            $.ajax({
                url: '/Registro/ObtenerIndividuoDetalle',
                type: "GET",
                data: { id: id },
                async: false,
                success: function (data) {
                    self.IndividuoDetalle(new IndividuoDetalle(data.schema));
                }
            });

        };
        self.IndividuoDetalle = ko.observable();

        self.NombreCompleto = ko.computed(function () {
            var current = self.IndividuoDetalle();
            if (current != null)
                return current.Nombres() + " " + current.PrimerApellido();
        }, self);
    };

    var individuoDetalleControl = new IndividuoDetalleViewModel();
    ko.applyBindings(individuoDetalleControl, document.getElementById("smallUserDetail"));
</script>
